package project.menu;

import java.util.ArrayList;

import project.menu.garagemenu.CreatorGarage;
import project.menu.garagemenu.ExportGarage;
import project.menu.garagemenu.ImportGarage;
import project.menu.garagemenu.ListFreeGarage;
import project.menu.garagemenu.NextFreeDate;
import project.menu.garagemenu.NumberFreePlacesOnDate;
import project.menu.garagemenu.RemoverGarage;
import project.menu.mainmenu.ExitItem;
import project.menu.mainmenu.MainMenu;
import project.menu.mainmenu.WorkerWithGarage;
import project.menu.mainmenu.WorkerWithMaster;
import project.menu.mainmenu.WorkerWithOrder;
import project.menu.mastermenu.CreatorMaster;
import project.menu.mastermenu.ExportMaster;
import project.menu.mastermenu.ImportMaster;
import project.menu.mastermenu.ListMasters;
import project.menu.mastermenu.MasterByOrder;
import project.menu.mastermenu.RemoverMaster;
import project.menu.mastermenu.listmenu.MastersByEmployment;
import project.menu.mastermenu.listmenu.MastersByName;
import project.menu.ordermenu.CopyOrder;
import project.menu.ordermenu.CreatorOrder;
import project.menu.ordermenu.ExportOrder;
import project.menu.ordermenu.ImportOrder;
import project.menu.ordermenu.MarkerOrder;
import project.menu.ordermenu.OffsetOrdersDeadlineDate;
import project.menu.ordermenu.OrderByMaster;
import project.menu.ordermenu.OrdersList;
import project.menu.ordermenu.listallorders.AllOrdersByBeginingDate;
import project.menu.ordermenu.listallorders.AllOrdersByDeadlineDate;
import project.menu.ordermenu.listallorders.AllOrdersByFillingDate;
import project.menu.ordermenu.listallorders.AllOrdersByPrice;
import project.menu.ordermenu.listallorders.ListAllOrders;
import project.menu.ordermenu.listcanceledorders.CanceledOrdersByBeginingDate;
import project.menu.ordermenu.listcanceledorders.CanceledOrdersByDeadlineDate;
import project.menu.ordermenu.listcanceledorders.CanceledOrdersByFillingDate;
import project.menu.ordermenu.listcanceledorders.CanceledOrdersByPrice;
import project.menu.ordermenu.listcanceledorders.ListCanceledOrders;
import project.menu.ordermenu.listdeletedorders.DeletedIOrdersByBeginingDate;
import project.menu.ordermenu.listdeletedorders.DeletedOrdersByDeadlineDate;
import project.menu.ordermenu.listdeletedorders.DeletedOrdersByFillingDate;
import project.menu.ordermenu.listdeletedorders.DeletedOrdersByPrice;
import project.menu.ordermenu.listdeletedorders.ListDeletedOrders;
import project.menu.ordermenu.listmadedorders.ListMadedOrders;
import project.menu.ordermenu.listmadedorders.MadedOrdersByBeginingDate;
import project.menu.ordermenu.listmadedorders.MadedOrdersByDeadlineDate;
import project.menu.ordermenu.listmadedorders.MadedOrdersByFillingDate;
import project.menu.ordermenu.listmadedorders.MadedOrdersByPrice;
import project.menu.ordermenu.listmadingorders.ListMadingOrders;
import project.menu.ordermenu.listmadingorders.MadingOrdersByBeginingDate;
import project.menu.ordermenu.listmadingorders.MadingOrdersByDeadlineDate;
import project.menu.ordermenu.listmadingorders.MadingOrdersByFillingDate;
import project.menu.ordermenu.listmadingorders.MadingOrdersByPrice;
import project.menu.ordermenu.markerorder.OrderCanceledStatus;
import project.menu.ordermenu.markerorder.OrderDeletedStatus;
import project.menu.ordermenu.markerorder.OrderMadedStatus;

public class Builder {

	public static void build() {
		// create collection for menu
		ArrayList<IMenuItem> mainMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> garageMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> sortMastersMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> masterMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> sortAllOrdersMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> sortCanceledOrdersMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> sortDeletedOrdersMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> sortMadedOrdersMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> sortMadingOrdersMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> getOrderListMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> markOrderMenu = new ArrayList<IMenuItem>();
		ArrayList<IMenuItem> orderMenu = new ArrayList<IMenuItem>();

		// create menu
		IMenu GARAGE_MENU = new Menu();
		IMenu MASTER_MENU = new Menu();
		IMenu SORTED_MASTERS_MENU = new Menu();
		IMenu ORDER_MENU = new Menu();
		IMenu ORDER_LIST_MENU = new Menu();
		IMenu ALL_ORDERS_MENU = new Menu();
		IMenu CANCELED_ORDERS_MENU = new Menu();
		IMenu DELETED_ORDERS_MENU = new Menu();
		IMenu MADED_ORDERS_MENU = new Menu();
		IMenu MADING_ORDERS_MENU = new Menu();
		IMenu ORDER_STATUS_MENU = new Menu();

		// create menuItems

		Back backInMainMenu = new Back();
		Back backInMasterMenu = new Back();
		Back backInOrderMenu = new Back();
		Back backInAllOrderMenu = new Back();
		
		

		ListFreeGarage listFreeGarage = new ListFreeGarage();
		NumberFreePlacesOnDate numberFreePlacesOnDate = new NumberFreePlacesOnDate();
		NextFreeDate nextFreeDate = new NextFreeDate();
		CreatorGarage creatorGarage = new CreatorGarage();
		RemoverGarage removerGarage = new RemoverGarage();
		ExportGarage exportGarage = new ExportGarage();
		ImportGarage importGarage = new ImportGarage();
		WorkerWithGarage workerWithGarage = new WorkerWithGarage();

		MastersByName mastersByName = new MastersByName();
		MastersByEmployment mastersByEmployment = new MastersByEmployment();
		ListMasters listMasters = new ListMasters();
		MasterByOrder masterByOrder = new MasterByOrder();
		CreatorMaster creatorMaster = new CreatorMaster();
		RemoverMaster removerMaster = new RemoverMaster();
		ExportMaster exportMaster = new ExportMaster();
		ImportMaster importMaster = new ImportMaster();
		WorkerWithMaster workerWithMaster = new WorkerWithMaster();

		AllOrdersByFillingDate allOrdersByFillingDate = new AllOrdersByFillingDate();
		AllOrdersByBeginingDate allOrdersByBeginingDate = new AllOrdersByBeginingDate();
		AllOrdersByDeadlineDate allOrdersByDeadlineDate = new AllOrdersByDeadlineDate();
		AllOrdersByPrice allOrdersByPrice = new AllOrdersByPrice();
		ListAllOrders listAllOrders = new ListAllOrders();
		CanceledOrdersByFillingDate canceledOrdersByFillingDate = new CanceledOrdersByFillingDate();
		CanceledOrdersByBeginingDate canceledOrdersByBeginingDate = new CanceledOrdersByBeginingDate();
		CanceledOrdersByDeadlineDate canceledOrdersByDeadlineDate = new CanceledOrdersByDeadlineDate();
		CanceledOrdersByPrice canceledOrdersByPrice = new CanceledOrdersByPrice();
		ListCanceledOrders listCanceledOrders = new ListCanceledOrders();
		DeletedOrdersByFillingDate deletedOrdersByFillingDate = new DeletedOrdersByFillingDate();
		DeletedIOrdersByBeginingDate deletedIOrdersByBeginingDate = new DeletedIOrdersByBeginingDate();
		DeletedOrdersByDeadlineDate deletedOrdersByDeadlineDate = new DeletedOrdersByDeadlineDate();
		DeletedOrdersByPrice deletedOrdersByPrice = new DeletedOrdersByPrice();
		ListDeletedOrders listDeletedOrders = new ListDeletedOrders();
		MadedOrdersByFillingDate madedOrdersByFillingDate = new MadedOrdersByFillingDate();
		MadedOrdersByBeginingDate madedOrdersByBeginingDate = new MadedOrdersByBeginingDate();
		MadedOrdersByDeadlineDate madedOrdersByDeadlineDate = new MadedOrdersByDeadlineDate();
		MadedOrdersByPrice madedOrdersByPrice = new MadedOrdersByPrice();
		ListMadedOrders listMadedOrders = new ListMadedOrders();
		MadingOrdersByFillingDate madingOrdersByFillingDate = new MadingOrdersByFillingDate();
		MadingOrdersByBeginingDate madingOrdersByBeginingDate = new MadingOrdersByBeginingDate();
		MadingOrdersByDeadlineDate madingOrdersByDeadlineDate = new MadingOrdersByDeadlineDate();
		MadingOrdersByPrice madingOrdersByPrice = new MadingOrdersByPrice();
		ListMadingOrders listMadingOrders = new ListMadingOrders();
		OrdersList ordersList = new OrdersList();
		OrderDeletedStatus orderDeletedStatus = new OrderDeletedStatus();
		OrderCanceledStatus orderCanceledStatus = new OrderCanceledStatus();
		OrderMadedStatus orderMadedStatus = new OrderMadedStatus();
		MarkerOrder markerOrder = new MarkerOrder();
		OrderByMaster orderByMaster = new OrderByMaster();
		CreatorOrder creatorOrder = new CreatorOrder();
		OffsetOrdersDeadlineDate offsetOrdersDeadlineDate = new OffsetOrdersDeadlineDate();
		CopyOrder copyOrder = new CopyOrder();
		ExportOrder exportOrder = new ExportOrder();
		ImportOrder importOrder = new ImportOrder();
		WorkerWithOrder workerWithOrder = new WorkerWithOrder();

		ExitItem exitItem = new ExitItem();

		backInMainMenu.setSubmenu(MainMenu.MAINMENU);

		// create garage menu
		garageMenu.add(listFreeGarage);
		garageMenu.add(numberFreePlacesOnDate);
		garageMenu.add(nextFreeDate);
		garageMenu.add(creatorGarage);
		garageMenu.add(removerGarage);
		garageMenu.add(exportGarage);
		garageMenu.add(importGarage);
		garageMenu.add(backInMainMenu);

		GARAGE_MENU.setMenu(garageMenu);
		workerWithGarage.setSubmenu(GARAGE_MENU);
		listFreeGarage.setSubmenu(GARAGE_MENU);
		numberFreePlacesOnDate.setSubmenu(GARAGE_MENU);
		nextFreeDate.setSubmenu(GARAGE_MENU);
		creatorGarage.setSubmenu(GARAGE_MENU);
		removerGarage.setSubmenu(GARAGE_MENU);
		exportGarage.setSubmenu(GARAGE_MENU);
		importGarage.setSubmenu(GARAGE_MENU);

		// create sort submenu

		backInMasterMenu.setSubmenu(MASTER_MENU);
		sortMastersMenu.add(mastersByName);
		sortMastersMenu.add(mastersByEmployment);
		sortMastersMenu.add(backInMasterMenu);

		SORTED_MASTERS_MENU.setMenu(sortMastersMenu);
		listMasters.setSubmenu(SORTED_MASTERS_MENU);
		mastersByName.setSubmenu(SORTED_MASTERS_MENU);
		mastersByEmployment.setSubmenu(SORTED_MASTERS_MENU);

		// create master menu

		masterMenu.add(listMasters);
		masterMenu.add(masterByOrder);
		masterMenu.add(creatorMaster);
		masterMenu.add(removerMaster);
		masterMenu.add(exportMaster);
		masterMenu.add(importMaster);
		masterMenu.add(backInMainMenu);
		MASTER_MENU.setMenu(masterMenu);

		workerWithMaster.setSubmenu(MASTER_MENU);
		creatorMaster.setSubmenu(MASTER_MENU);
		removerMaster.setSubmenu(MASTER_MENU);
		masterByOrder.setSubmenu(MASTER_MENU);
		exportMaster.setSubmenu(MASTER_MENU);
		importMaster.setSubmenu(MASTER_MENU);

		// create orders menu backInAllOrderMenu.setMenu(ORDER_LIST_MENU);
		backInOrderMenu.setSubmenu(ORDER_MENU);
		// create sortallordersby_menu

		sortAllOrdersMenu.add(allOrdersByFillingDate);
		sortAllOrdersMenu.add(allOrdersByBeginingDate);
		sortAllOrdersMenu.add(allOrdersByDeadlineDate);
		sortAllOrdersMenu.add(allOrdersByPrice);
		sortAllOrdersMenu.add(backInAllOrderMenu);
		ALL_ORDERS_MENU.setMenu(sortAllOrdersMenu);
		listAllOrders.setSubmenu(ALL_ORDERS_MENU);
		allOrdersByFillingDate.setSubmenu(ALL_ORDERS_MENU);
		allOrdersByBeginingDate.setSubmenu(ALL_ORDERS_MENU);
		allOrdersByDeadlineDate.setSubmenu(ALL_ORDERS_MENU);
		allOrdersByPrice.setSubmenu(ALL_ORDERS_MENU);
		backInAllOrderMenu.setSubmenu(ORDER_LIST_MENU);

		// create sortcanceledordersby_menu

		sortCanceledOrdersMenu.add(canceledOrdersByFillingDate);
		sortCanceledOrdersMenu.add(canceledOrdersByBeginingDate);
		sortCanceledOrdersMenu.add(canceledOrdersByDeadlineDate);
		sortCanceledOrdersMenu.add(canceledOrdersByPrice);
		sortCanceledOrdersMenu.add(backInAllOrderMenu);
		CANCELED_ORDERS_MENU.setMenu(sortCanceledOrdersMenu);
		listCanceledOrders.setSubmenu(CANCELED_ORDERS_MENU);
		canceledOrdersByFillingDate.setSubmenu(CANCELED_ORDERS_MENU);
		canceledOrdersByBeginingDate.setSubmenu(CANCELED_ORDERS_MENU);
		canceledOrdersByDeadlineDate.setSubmenu(CANCELED_ORDERS_MENU);
		canceledOrdersByPrice.setSubmenu(CANCELED_ORDERS_MENU);

		// create sortdeletedordersby_menu

		sortDeletedOrdersMenu.add(deletedOrdersByFillingDate);
		sortDeletedOrdersMenu.add(deletedIOrdersByBeginingDate);
		sortDeletedOrdersMenu.add(deletedOrdersByDeadlineDate);
		sortDeletedOrdersMenu.add(deletedOrdersByPrice);
		sortDeletedOrdersMenu.add(backInAllOrderMenu);

		DELETED_ORDERS_MENU.setMenu(sortDeletedOrdersMenu);
		listDeletedOrders.setSubmenu(DELETED_ORDERS_MENU);
		deletedOrdersByFillingDate.setSubmenu(DELETED_ORDERS_MENU);
		deletedIOrdersByBeginingDate.setSubmenu(DELETED_ORDERS_MENU);
		deletedOrdersByDeadlineDate.setSubmenu(DELETED_ORDERS_MENU);
		deletedOrdersByPrice.setSubmenu(DELETED_ORDERS_MENU);

		// create sortmadedordersby_menu

		sortMadedOrdersMenu.add(madedOrdersByFillingDate);
		sortMadedOrdersMenu.add(madedOrdersByBeginingDate);
		sortMadedOrdersMenu.add(madedOrdersByDeadlineDate);
		sortMadedOrdersMenu.add(madedOrdersByPrice);
		sortMadedOrdersMenu.add(backInAllOrderMenu);
		MADED_ORDERS_MENU.setMenu(sortMadedOrdersMenu);
		listMadedOrders.setSubmenu(MADED_ORDERS_MENU);
		madedOrdersByFillingDate.setSubmenu(MADED_ORDERS_MENU);
		madedOrdersByBeginingDate.setSubmenu(MADED_ORDERS_MENU);
		madedOrdersByDeadlineDate.setSubmenu(MADED_ORDERS_MENU);
		madedOrdersByPrice.setSubmenu(MADED_ORDERS_MENU);

		// create sortmadingordersby_menu

		sortMadingOrdersMenu.add(madingOrdersByFillingDate);
		sortMadingOrdersMenu.add(madingOrdersByBeginingDate);
		sortMadingOrdersMenu.add(madingOrdersByDeadlineDate);
		sortMadingOrdersMenu.add(madingOrdersByPrice);
		sortMadingOrdersMenu.add(backInAllOrderMenu);
		MADING_ORDERS_MENU.setMenu(sortMadingOrdersMenu);
		listMadingOrders.setSubmenu(MADING_ORDERS_MENU);
		madingOrdersByFillingDate.setSubmenu(MADING_ORDERS_MENU);
		madingOrdersByBeginingDate.setSubmenu(MADING_ORDERS_MENU);
		madingOrdersByDeadlineDate.setSubmenu(MADING_ORDERS_MENU);
		madingOrdersByPrice.setSubmenu(MADING_ORDERS_MENU);

		// create getorderlistmenu

		getOrderListMenu.add(listAllOrders);
		getOrderListMenu.add(listDeletedOrders);
		getOrderListMenu.add(listCanceledOrders);
		getOrderListMenu.add(listMadedOrders);
		getOrderListMenu.add(listMadingOrders);
		getOrderListMenu.add(backInOrderMenu);
		ORDER_LIST_MENU.setMenu(getOrderListMenu);
		ordersList.setSubmenu(ORDER_LIST_MENU);

		// create markordermenu

		markOrderMenu.add(orderDeletedStatus);
		markOrderMenu.add(orderCanceledStatus);
		markOrderMenu.add(orderMadedStatus);
		markOrderMenu.add(backInOrderMenu);
		ORDER_STATUS_MENU.setMenu(markOrderMenu);
		markerOrder.setSubmenu(ORDER_STATUS_MENU);
		orderDeletedStatus.setSubmenu(ORDER_STATUS_MENU);
		orderCanceledStatus.setSubmenu(ORDER_STATUS_MENU);
		orderMadedStatus.setSubmenu(ORDER_STATUS_MENU);
		// create order menu

		orderMenu.add(ordersList);
		orderMenu.add(orderByMaster);
		orderMenu.add(markerOrder);
		orderMenu.add(creatorOrder);
		orderMenu.add(offsetOrdersDeadlineDate);
		orderMenu.add(copyOrder);
		orderMenu.add(exportOrder);
		orderMenu.add(importOrder);
		orderMenu.add(backInMainMenu);
		ORDER_MENU.setMenu(orderMenu);
		workerWithOrder.setSubmenu(ORDER_MENU);
		orderByMaster.setSubmenu(ORDER_MENU);
		creatorOrder.setSubmenu(ORDER_MENU);
		offsetOrdersDeadlineDate.setSubmenu(ORDER_MENU);
		copyOrder.setSubmenu(ORDER_MENU);
		exportOrder.setSubmenu(ORDER_MENU);
		importOrder.setSubmenu(ORDER_MENU);

		// create resavedata menu

		// create main menu
		mainMenu.add(workerWithGarage);
		mainMenu.add(workerWithMaster);
		mainMenu.add(workerWithOrder);
		mainMenu.add(exitItem);
		MainMenu.MAINMENU.setMenu(mainMenu);

	}
}
